package com.sdry.approval.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sdry.system.entity.SysUser;
import com.sdry.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @program: produce_sdry
 * @description: 发起审批
 * @author: cb
 * @create: 2020-02-08 19:07
 **/
@Controller
@RequestMapping(value = "sponsor")
public class SponsorApprovalController {

    @Autowired
    private UserService userService;

    /**
     * 发起审批
     * @return
     */
    @RequestMapping(value = "showSponsor")
    public String showSponsor() {
        return "/approval/sponsor";
    }

    /**
     * 我发起的
     * @return
     */
    @RequestMapping(value = "showMeSponsor")
    public String showMeSponsor() {
        return "/approval/meSponsor";
    }


    /**
     * 抄送我
     * @return
     */
    @RequestMapping(value = "showCopyApproved")
    public String showCopyApproved() {
        return "/approval/copyApproved";
    }


    /**
     * 我已审批
     * @return
     */
    @RequestMapping(value = "showAlreadyApproved")
    public String showAlreadyApproved() {
        return "/approval/alreadyApproved";
    }


    /**
     * 待我审批
     * @return
     */
    @RequestMapping(value = "showForMyApproval")
    public String showForMyApproval() {
        return "/approval/forMyApproval";
    }


    /**
     * 请假申请
     * @return
     */
    @RequestMapping(value = "/apply/showLeave")
    public String showLeave(Model model) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("del_flag",0L).eq("log_on",0L).select("user_id","real_name");
        List<SysUser> sysUserList = userService.list(queryWrapper);
        model.addAttribute("sysUserList",sysUserList);
        return "/approval/apply/leave";
    }


    /**
     * 维修申请
     * @return
     */
    @RequestMapping(value = "/apply/repair")
    public String repair() {
        return "/approval/apply/repair";
    }

}
